<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <title>呼叫中心运营平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/non-responsive.css">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="/css/global.css">
    <link rel="stylesheet" type="text/css" href="/css/company.css">
  </head>
  <body>
    <nav class="navbar navbar-inverse navbar-static-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#"><img alt="Logo" src="/img/logo.png"></a>
          <a class="navbar-brand" href="#">运营平台</a>
        </div>
        <div id="navbar">
          <ul class="nav navbar-nav">
            <li><a href="/company">企业管理</a></li>
            <li><a href="/task">任务监控</a></li>
            <li><a href="/user">账户管理</a></li>
            <li><a href="/agent">座席管理</a></li>
            <li><a href="/sound">语音管理</a></li>
            <li><a href="/service">服务管理</a></li>
            <li class="dropdown active">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 系统管理
              </a>
              <ul class="dropdown-menu">
                <li><a href="/gateway">中继网关</a></li>
                <li><a href="/status">服务器状态</a></li>
                <li><a href="/logs">日志记录</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a><img class="img-circle icon" src="/img/<?php echo $user->icon; ?>.png" width="19" height="19"> <?php echo $user->name; ?></a></li>
            <li><a href="/logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 退 出</a></li>
          </ul>
        </div>
      </div>
    </nav>
    <div class="container box">
      <div>
        <ol class="breadcrumb">
          <li>当前位置:</li>
          <li>中继网关</li>
          <li class="active">所有网关</li>
          <li class="pull-right" style="margin-right: 6px"><a class="btn btn-default btn-xs" href="/gateway"><span class="glyphicon glyphicon-repeat"></span> 刷 新</a></li>
        </ol>
      </div>
      <div>
        <table class="table table-condensed table-striped table-hover">
          <thead>
            <tr>
              <th>#</th>
              <th>中继名称</th>
              <th>所属公司</th>
              <th>中继状态</th>
              <th>中继账号</th>
              <th>中继网关IP地址</th>
              <th>编辑操作</th>
            </tr>
          </thead>
          <tbody class="text-muted">
          <?php
          if ($gateways != null && count($gateways) > 0) {
              foreach ($gateways as $gateway) {
                echo '<tr>',"\n";
                echo '<td><span class="glyphicon glyphicon-flash"></span></td>',"\n";
                echo '<td>trunk.',$gateway['company'],'.gw</td>',"\n";
                if ($companys != null) {
                  echo '<td>',$companys[$gateway['company']]['name'],'</td>',"\n";
                } else {
                  echo '<td text-danger>未知公司</td>',"\n";
                }
                
                if ($gateway['status']) {
                  if ($gateway['status']->status == 'UP') {
                    echo '<td><span class="label label-success">已注册</span></td>',"\n";
                  } else if ($gateway['status']->status == 'DOWN') {
                    echo '<td><span class="label label-default">未注册</span></td>',"\n";
                  }
                } else {
                  echo '<td><span class="label label-default">未知状态</span></td>',"\n";
                }

                echo '<td>',$gateway['username'],'</td>',"\n";
                echo '<td>',$gateway['ip_addr'],'</td>',"\n";
                echo '<td class="td-edit"><a class="btn btn-default btn-xs" href="/gateway/edit/',$gateway['company'],'"><span class="glyphicon glyphicon-edit"></span> 编 辑</a></td>',"\n";
                echo '</tr>',"\n";
              }       
          }
          ?>
          </tbody>
        </table>
      </div>
    </div>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript">
      $('li.dropdown').mouseover(function() {   
        $(this).addClass('open');
      }).mouseout(function() {
        $(this).removeClass('open');
      });
    </script>
  </body>
</html>
